package cn.jy.machine.mapper;

import cn.jy.common.machine.domain.ExpressBoxes;
import cn.jy.common.machine.domain.UseCountMap;
import cn.jy.common.machine.domain.dto.ExpressBoxesDto;
import cn.jy.common.machine.domain.vo.ExpressBoxesVo;
import cn.jy.common.machine.domain.vo.ExpressVendingMachinesVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @author lenovo
* @description 针对表【express_boxes】的数据库操作Mapper
* @createDate 2024-08-26 19:36:24
* @Entity cn.jy.common.machine.domain.ExpressBoxes
*/
public interface ExpressBoxesMapper {

    void insert(ExpressBoxes box);

    void insertBatch(List<ExpressBoxes> boxes);


    @Select("<script>" +
            "SELECT machine_id AS id, COUNT(*) AS useCount " +
            "FROM express_boxes " +
            "WHERE machine_id IN " +
            "<foreach item='item' index='index' collection='arrayList' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "AND is_status = 1 " +
            "GROUP BY machine_id" +
            "</script>")
    List<UseCountMap> selectBoxes(@Param("arrayList") List<Integer> arrayList);

    @Select("select is_status from express_boxes where machine_id = #{id}")
    List<ExpressBoxes> findBoxesById(Integer id);

    List<ExpressBoxesDto> findBoxList(ExpressBoxesVo vo);

    void updateBox(ExpressBoxes boxes);

    @Select("select * from express_boxes where id = #{id}")
    ExpressBoxes findBox(Integer id);

    ExpressBoxesDto findBoxById(Integer id);
}




